package com.sunda.spmsorder.mapper;

import com.sunda.spmsorder.entity.MaterialSrmLongContract;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * SRM长协表 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2021-01-25
 */
@Component
@Mapper
public interface MaterialSrmLongContractMapper extends BaseMapper<MaterialSrmLongContract> {

    @Select("<script>SELECT srm.LONG_CONTRACT_CODE AS \"longContractCode\",\n" +
            "  srm.SUPPLIER_CODE AS \"supplierCode\",\n" +
            "  srm.SUPPLIER_NAME AS \"supplierName\",\n" +
            "  srm.BRAND AS \"brand\"\n" +
            "FROM MATERIAL_SRM_LONG_CONTRACT srm\n" +
            "WHERE srm.MATERIAL_NO IN " +
            "<foreach item='item' index='index' collection='materialNoList' open='(' separator=',' close=')'>\n" +
            "       #{item} \n" +
            "</foreach>" +
            "</script>")
    List<Map<String, Object>> getByMaterialNoList(@Param("materialNoList") List<String> materialNoList);

    @Select("SELECT srm.LONG_CONTRACT_CODE AS \"longContractCode\",\n" +
            "  srm.SUPPLIER_CODE AS \"supplierCode\",\n" +
            "  srm.SUPPLIER_NAME AS \"supplierName\",\n" +
            "  srm.BRAND AS \"brand\"\n" +
            "FROM MATERIAL_SRM_LONG_CONTRACT srm\n" +
            "WHERE srm.MATERIAL_NO IN #{materialNo}")
    List<Map<String, Object>> getByMaterialNo(@Param("materialNo") String materialNo);
}
